import service from "../util/service";
export function apilink(url,method,params){
    if(method === "get"){
        if(params){
            return new Promise((resolve,reject)=>{
                service.request({
                    url,
                    method:"get",
                    params
                }).then((ok)=>{
                    resolve(ok)
                }).catch((err)=>{
                    reject(err)
                })
            })
        }else{
            return new Promise((resolve,reject)=>{
                service.request({
                    url,
                    method:"get",
                }).then((ok)=>{
                    resolve(ok)
                }).catch((err)=>{
                    reject(err)
                })
            })
        }
    }
    if(method === "post"){
        return new Promise((resolve,reject)=>{
            if(params){
                service.request({
                    url,
                    method,
                    data:params
                }).then((ok)=>{
                    resolve(ok)
                }).catch((err)=>{
                    reject(err)
                })
            }else{
                service.request({
                    url,
                    method,
                }).then((ok)=>{
                    resolve(ok)
                }).catch((err)=>{
                    reject(err)
                })
            }
        })
    }
}


